package com.csgc.camera.biz.other.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView.Adapter
import androidx.recyclerview.widget.RecyclerView.ViewHolder

import com.csgc.camera.util.clickWithTrigger
import com.cysd.spsyxj.R
import com.cysd.spsyxj.databinding.ItemGuideBinding


class GuidePageAdapter(val context:Context):Adapter<GuidePageAdapter.GuidePageHolder>() {

    var listener:OnNextListener?=null
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): GuidePageHolder {
        return GuidePageHolder(ItemGuideBinding.inflate(LayoutInflater.from(context),parent,false))

    }

    override fun onBindViewHolder(holder: GuidePageHolder, position: Int) {
        holder.binding.apply {
            if(position == 0){
                tvTips1.text = "个性水印"
                tvTips2.text = "定制"
                tvCameraTips.text = "灵活定义水印内容，满足个人需求"
                layoutPoint1.visibility = View.VISIBLE
                layoutPoint2.visibility = View.GONE
                layoutPoint3.visibility = View.GONE
                tvNextPage.text = "下一个"
                ivGuideImage.setImageResource(R.drawable.img_guide_page_1)
            }else if(position == 1){
                tvTips1.text = "海量水印"
                tvTips2.text = "拍照"
                tvCameraTips.text = "多种行业水印，满足工作需求"
                layoutPoint1.visibility = View.GONE
                layoutPoint2.visibility = View.VISIBLE
                layoutPoint3.visibility = View.GONE
                tvNextPage.text = "下一个"
                ivGuideImage.setImageResource(R.drawable.img_guide_page_2)
            }else if(position == 2){
                tvTips1.text = "视频打卡"
                tvTips2.text = "拍照"
                tvCameraTips.text = "多种拍摄方法任意选择"

                layoutPoint1.visibility = View.GONE
                layoutPoint2.visibility = View.GONE
                layoutPoint3.visibility = View.VISIBLE
                tvNextPage.text = "完成"
                ivGuideImage.setImageResource(R.drawable.img_guide_page_3)
            }

            tvNextPage.clickWithTrigger {
                listener?.onNext(position)
            }

        }
    }

    override fun getItemCount(): Int {
        return 3
    }

    class GuidePageHolder(val binding:ItemGuideBinding):ViewHolder(binding.root)

    interface OnNextListener{
        fun onNext(position: Int)
    }
}